'''
Created on Jul 16, 2012

@author: catapult
'''

import pygame
'''from pygame.locals import QUIT'''

varList = []
rend = []

# Initialise screen
text = 'aa'
message = 'aa'

class TextBox():

    def __init__(self):
        self.rend = [pygame.Surface((0, 0)), pygame.Surface((0, 0)), pygame.Surface((0, 0)), pygame.Surface((0, 0))]

    def addMessage(self, mode = 1, var1 = ' ', var2 = ' '):

        # Initialise screen

        background = pygame.Surface((512, 87))
        background = background.convert()
        background.fill((250, 250, 250))

        font = pygame.font.Font(None, 22)
        if mode == 0: #regular effect
            message = str(var1) + ' used ' + str(var2) + '.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 1: #miss
            message = str(var1) + '\'s attack missed.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 2: #super effective
            message ='Its super effective.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 3: #not very effecive
            message ='Its not very effective.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 4: #no effect
            message ='The attack had no effect.'
            text = font.render (message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 5: #normal crit
            message ='It\'s a critical hit.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 6: #faint
            message = str(var1) + ' fainted.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 7: #switch out
            message = str(var1) + ' come back!'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 8: #item use
            message = str(var1) + ' was used on ' + str(var2) + '.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 9: #splash hits...
            message = 'Uh oh...'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 10: #recoil
            message = str(var1) + ' was hit by recoil.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)
            
        elif mode == 11: #become confused
            message = str(var1) + ' became confused.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 12: #snap out of confusion
            message = str(var1) + ' snapped out of it\'s confusion.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 13: #confusion damage
            message = str(var1) + ' hurt itself in it\'s confusion.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 14: #burn
            message = str(var1) + ' is hurt by it\'s burn.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 15: #poison
            message = str(var1) + ' is poisoned.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 16: #paralyze
            message = str(var1) + ' is paralyzed. It can\'t move!'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 17: #sleep
            message = str(var1) + ' is fast asleep.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 18: #Wake up
            message = str(var1) + ' woke up.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 19: #frozen
            message = str(var1) + ' is frozen solid.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 20: #defrost
            message = str(var1) + ' has thawed out.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 21: #recharge
            message = str(var1) + ' must recharge.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 22: #switch in
            message = 'GO ' + str(var1) +'!'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 23: #rain begin
            message = 'It began to rain.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 24: #raining
            message = 'It is raining.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 25: #hail begin
            message = 'It began to hail.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 26: #hail
            message = 'It is hailing.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 27: #sun begin
            message = 'The sunlight became bright.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 28: #sun
            message = 'The sun is bright.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 29: #normal weather return
            message = 'The weather returned to normal.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)
            
        elif mode == 31: #is confused
            message = str(var1) + ' is confused.'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        elif mode == 30: #custom
            message = var1
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x
            varList.append(message)

        else: #error
            message = 'ERROR'
            text = font.render(message, 1, (10, 10, 10))
            textpos = text.get_rect()
            textpos.x = background.get_rect().x 
            varList.append(message)       

        # Blit everything to the screen
        self.rend[0] = self.rend[1]
        self.rend[1] = self.rend[2]
        self.rend[2] = self.rend[3]
        self.rend[3] = text
        self.blahblahblah = pygame.Surface((512, 87))
        font = pygame.font.Font(None, 22)
        message = font.render(message, 0,(0, 0, 0))
        textpos = text.get_rect()
        textpos.x = background.get_rect().x
        background.blit(self.rend[0], (0, 10))
        background.blit(self.rend[1], (0, 25))
        background.blit(self.rend[2], (0, 40))
        background.blit(self.rend[3], (0, 55))
        self.blahblahblah.blit(background, (0, 0))
        
        
    def getDisp(self):
        return self.blahblahblah


    
varList = []
